﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SC2Ranks.Web
{
    internal static class Helper
    {
        public static Dictionary<string, string> GetImageCss(IImageInfo imageInfo, string imagesFormatPath, PortraitSize pSize)
        {
            int size = (int)pSize;

            var result = new Dictionary<string, string> 
            {
                { "width", string.Format( "{0}px",size) },
                { "height", string.Format( "{0}px",size) },
                { "background-color", "#000" }
            };

            if (imageInfo != null)
            {
                var url = string.Format(imagesFormatPath, imageInfo.IconID, size);
                var shiftRow = -(imageInfo.Row * size);
                var shiftCol = -(imageInfo.Column * size);

                result.Add("background-image", string.Format("url('{0}')", url));
                result.Add("background", string.Format(@" {0}px {1}px no-repeat", shiftCol, shiftRow));
            }

            return result;
        }
    }
}
